<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2016/3/15
 * Time: 11:32
 */

echo "<title>8-6 判断函数是否存在</title>";
echo "<p style='text-align: center'><a href=\"index.php\"><font size=\"4\">目录</font></a></p>";
header("Content-type: text/html; charset=utf-8");
echo "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />";

function func(){
    echo 'exists';
}
$name = 'func';
if(function_exists('func')){
    $name();
}


//类是否定义用exists判断
class MyClass{

}
//使用前检查类是否存在
if(class_exists('MyClass')){
    $myclass = new MyClass();
}
print_r($myclass);


//file_exists判断文件是否存在















